<!DOCTYPE html>

<html>
	<head>
		{{template "bootstrap"}}
		<title> 服务器管理 </title>
		
	</head>

	<body style="padding-top:80px">
  		{{template "nav" .}}

		<div class="container" style="width:500px">
			<form method="GET" action="/smanager/addserver">
			  <div class="form-group">
			    <h1>添加服务器</h1>
				<input id="svid" class="form-control"  placeholder="该类服务器唯一ID" name="svid">
			    <input id="name" class="form-control"  placeholder="输入服务器名称" name="name">
				<input id="addr" class="form-control"  placeholder="输入Ip地址：eg 192.168.100.157" name="addr">
				<input id="port" class="form-control"  placeholder="输入端口" name="port">
			  </div>
			  

			  <input id="stype" class="hidden" name="stype" value="{{.Stype}}" />
			  <button type="submit" class="btn btn-default" >添加 </button>
			</form>

			<table class="table table-striped">
				<thead>
					<th>Svid</th>
					<th>名称</th>
					<th>地址</th>
					<th>端口</th>
					<th>删除</th>
				</thead>

				<tbody>
					{{range .Servers}}
					<tr>
						<td>{{.Svid}}</th>
						<td>{{.Name}}</th>
						<td>{{.Addr}}</th>
						<td>{{.Port}}</th>
						<td>
							<a href="/smanager/delserver?id={{.Id}}"> 删除 </a>
						</td>
					</tr>
					{{end}}
				</tbody>
			</table>

		</div>

		<script type="text/javascript">

			function checkInput(){
				var name = document.getElementById("name");
				if (name.value.length == 0) {
					alert("请输入类型名称")
					return false
				}
				
				var desc = document.getElementById("desc");
				if (desc.value.length == 0) {
					alert("请输入类型描述")
					return false
				}

				return true
			}

			function backToHome() {
				window.location.href = "/"
				return false
			}
		</script>
	</body>
</html>